package com.sunwayworld.basemodule.rm.train.exam.validator;

import java.util.List;

import com.sunwayworld.basemodule.rm.train.exam.bean.LimsCoreExamBean;
import org.springframework.stereotype.Component;


import com.sunwayworld.framework.i18n.I18nHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.utils.DateTimeUtils;
import com.sunwayworld.framework.utils.ObjectUtils;
import com.sunwayworld.framework.utils.StringUtils;
import com.sunwayworld.framework.validator.data.DataValidator;

@Component
public class LimsCoreExamActivatableValidator implements DataValidator {

    public boolean doValid(Object... args) {
        RestJsonWrapperBean warpper = (RestJsonWrapperBean) args[0];
        
        List<LimsCoreExamBean> examList = warpper.parse(LimsCoreExamBean.class);
        
        boolean flag = true;
        
        for (int i = 0; i < examList.size(); i++) {
            boolean subFlag = true;
            StringBuilder validSb = new StringBuilder();
            
            LimsCoreExamBean exam = examList.get(i);
            
/*            if (ObjectUtils.isEmpty(exam.getExamBeginTime())) {
                validSb.append(exam.getExamName() + ":" + I18nHelper.getMessage("T_CORE_EXAM.EXAMBEGINTIME") + I18nHelper.getMessage("GIKAM.TRAIN.TIP.CANNOT_BE_EMPTY"));
                subFlag = false;
            }
            
            if (ObjectUtils.isEmpty(exam.getExamEndTime())) {
                if (subFlag) {
                    validSb.append(exam.getExamName() + ":" + I18nHelper.getMessage("T_CORE_EXAM.EXAMENDTIME") + I18nHelper.getMessage("GIKAM.TRAIN.TIP.CANNOT_BE_EMPTY"));
                    subFlag = false;
                } else {
                    validSb.append(";" + I18nHelper.getMessage("T_CORE_EXAM.EXAMENDTIME") + I18nHelper.getMessage("GIKAM.TRAIN.TIP.CANNOT_BE_EMPTY"));
                }
            }*/
            
/*            if (StringUtils.isEmpty(exam.getExamCategory())) {
                if (subFlag) {
                    validSb.append(exam.getExamName() + ":" + I18nHelper.getMessage("T_CORE_EXAM.EXAMCATEGORY") + I18nHelper.getMessage("GIKAM.TRAIN.TIP.CANNOT_BE_EMPTY"));
                    subFlag = false;
                } else {
                    validSb.append(";" + I18nHelper.getMessage("T_CORE_EXAM.EXAMCATEGORY") + I18nHelper.getMessage("GIKAM.TRAIN.TIP.CANNOT_BE_EMPTY"));
                }
            }*/
            
/*            if (exam.getExamDuration() == 0L) {
                if (subFlag) {
                    validSb.append(exam.getExamName() + ":" + I18nHelper.getMessage("T_CORE_EXAM.EXAMDURATION") + I18nHelper.getMessage("GIKAM.TRAIN.TIP.CANNOT_BE_EMPTY"));
                    subFlag = false;
                } else {
                    validSb.append(";" + I18nHelper.getMessage("T_CORE_EXAM.EXAMDURATION") + "不能等于0");
                }
            }*/
            
/*            if (DateTimeUtils.isBefore(exam.getExamEndTime(), exam.getExamBeginTime())) {
                if (subFlag) {
                    validSb.append(exam.getExamName() + ":" + "考试结束时间不能早于考试结束时间");
                    subFlag = false;
                } else {
                    validSb.append(";" + "考试结束时间不能早于考试结束时间");
                }
            }*/
            
            if (!subFlag) {
                flag = subFlag;
                addConstraintViolation(validSb.toString());
            }
        }
        return flag;
    }
}